package com.szty.libarytest.other

import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.szty.libarytest.R
import kotlinx.android.synthetic.main.activity_katex.*

class KatexActivity : AppCompatActivity() {
    private var isClick = false
    set(value) {
        field = value
        if(value){
            "修改值为true".loge()
            Thread{
                Thread.sleep(3000)
                "到时间了,修改值".loge()
                field = false
            }.start()
        }
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_katex)
        val arrayOf = arrayOf<String>()
        btn_test.setOnClickListener {
            if(isClick){
                "当前正在操作".loge()
                return@setOnClickListener
            }
            isClick = true
            "正在做事".loge()
//            val input =
//                "\t<br />（1）由曲线$ {C}_{1}$ 的参数方程消参可得曲线$ {C}_{1}$ 的普通方程为$ {x}^{2}+{\\left(y-\\sqrt{3}\\right)}^{2}=3\$；<br />曲线$ {C}_{2}$ 的极坐标方程可变为$ {\rho}^{2}=2\\rho \\mathit{cos}\\theta \$，<br />∴$ {C}_{2}$ 的直角坐标方程为$ {x}^{2}+{y}^{2}=2x$ 即$ {left(x - 1 right) }^{2}+{y}^{2}=1\$；<br />（2）曲线$ {C}_{1}$ 化为极坐标方程为\$\\rho =2\\sqrt{3}\\mathit{sin}\\theta \$，<br />设$ A\\left({\\rho }_{1},\\alpha \\right)\$，$ B\\left({\\rho }_{2},\\alpha \\right)\$，则$ {rho}_{1}=2\\sqrt{3}\\mathit{sin}\\alpha \$，$ {\rho}_{2}=2\\mathit{cos}\\alpha \$，<br />∴\$\\left|AB\\right.|=\\left|{\\rho }_{1}-{\\rho }_{2}\\right.|=\\left|2\\sqrt{3}\\mathit{sin}\\alpha -2\\mathit{cos}\\alpha \\right.|=4\\left|\\mathit{sin}\\left(\\alpha -\\frac{\\pi }{6}\\right)\\right.|\$，由\$\\left|AB\\right.|=2\\sqrt{2}$ 可知\$\\mathit{sin}\\left(\\alpha -\\frac{\\pi }{6}\\right)=±\\frac{\\sqrt{2}}{2}\$，<br />∵\$0 < \\alpha  < \\pi \$，∴\$-\\frac{\\pi }{6} < \\alpha -\\frac{\\pi }{6} < \\frac{5\\pi }{6}\$，∴\$\\alpha -\\frac{\\pi }{6}=\\frac{\\pi }{4}\\text{ }\\text{或}\\text{ }\\alpha -\\frac{\\pi }{6}=\\frac{3\\pi }{4}\$，∴\$\\alpha =\\frac{5\\pi }{12}$ 或\$\\alpha =\\frac{11\\pi }{12}\$.<br /><br />\n"
//            mv_math.setDisplayText(input)
//            startActivity(Intent(this,FragmentTestActivity::class.java))
        }

    }

    fun createCorrectImg(view: View): Bitmap {
        val createBitmap = Bitmap.createBitmap(
            view.width,
            view.height,
            Bitmap.Config.RGB_565
        )
        val canvas = Canvas(createBitmap)
        view.draw(canvas)
        return createBitmap
    }

}